package voyager.holodeck.car;

import star.trek.voyager.module.benz.BenzFactory;
import star.trek.voyager.module.benz.axletree_amg.AMGAxletree;
import star.trek.voyager.module.benz.car_sls_amg.BenzSlsAmg;
import star.trek.voyager.module.benz.engine_v9.EngineV9;
import star.trek.voyager.module.benz.wheel_amg.AMGWheel;
import star.trek.voyager.module.common.etasocket_common.CommonETASocket;
import star.trek.voyager.blueprint.axletree_socket.AxletreeSocket;
import star.trek.voyager.blueprint.car.Car;
import star.trek.voyager.blueprint.etasocket.ETASocket;
import star.trek.voyager.blueprint.status.Status;

public class POJOAssembling {
	
	public static void defaultBenzSlsAmgShow(){
		Car benzSlsAmg = BenzFactory.getBenzSlsAmg();
		System.out.println("-----benzSlsAmg.getStatus-----");
		System.out.println(benzSlsAmg.getStatus());
		System.out.println("=====benzSlsAmg.getStatus=====");
	}
	
	public static void benzSlsAmgWithEngineV9Show(){
		Car benzSlsAmgWithV9 = getBenzSlsAmgV9();
		System.out.println("-----benzSlsAmgWithV9.getStatus-----");
		System.out.println(benzSlsAmgWithV9.getStatus());
		System.out.println("=====benzSlsAmgWithV9.getStatus=====");
	}
	private static Car getBenzSlsAmgV9(){
		BenzSlsAmg car = new BenzSlsAmg();
		
		//instance wheels
		AMGWheel w0 = new AMGWheel();
		AMGWheel w1 = new AMGWheel();
		
		//instance axletree and install wheels
		AMGAxletree axletree = new AMGAxletree();
		axletree.socket(w0, "0");
		axletree.socket(w1, "1");
		//init axletree
		axletree.init();
		
		//instance commonETASocket and install axletree
		CommonETASocket commonETASocket = new CommonETASocket();
		commonETASocket.socket((AxletreeSocket)axletree);
		commonETASocket.socket((Status)axletree);
		
		//instance engine and install 
		EngineV9 v9 = new EngineV9();
		v9.socket((ETASocket)commonETASocket);
		v9.socket((Status)commonETASocket);
		//register engine StatusOutput
		v9.socket(car);
		//init engine
		v9.init();
		
		//install engine to car
		car.setEngine(v9);
		car.init();
		
		return car;
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		//get a default BenzSlsAmg
		System.out.println("-----defaultBenzSlsAmgShow-----");
		defaultBenzSlsAmgShow();
		System.out.println("=====defaultBenzSlsAmgShow=====");
		
		System.out.println("-----benzSlsAmgWithEngineV9Show-----");
		benzSlsAmgWithEngineV9Show();
		System.out.println("=====benzSlsAmgWithEngineV9Show=====");
		
	}

}
